#ifndef InclusionGuard_SoundPotMainGui_h
#define InclusionGuard_SoundPotMainGui_h

#ifdef _MSC_VER
  #pragma pack (push, 8)
#endif

#ifdef _WIN32
  #include <windows.h>
#elif defined (LINUX)
  #include <X11/Xlib.h>
  #include <X11/Xutil.h>
  #include <X11/Xatom.h>
  #undef KeyPress
#else
  #include <Carbon/Carbon.h>
#endif

#include "juce.h"

#include "SoundPotMainAudioEffect.h"



//==============================================================================
/**
    This is the Component that our filter will use as its UI.

    One or more of these is created by the DemoJuceFilter::createEditor() method, 
    and they will be deleted at some later time by the wrapper code.
 
    To demonstrate the correct way of connecting a filter to its UI, this
    class is a ChangeListener, and our demo filter is a ChangeBroadcaster. The
    editor component registers with the filter when it's created and deregisters
    when it's destroyed. When the filter's parameters are changed, it broadcasts 
    a message and this editor responds by updating its display.
*/



namespace SoundPot
{

	class MainAudioEffect;

	class MainGui   : public Component,
				  public ChangeListener,
				  public SliderListener,
				  public AsyncUpdater // EditorCompWrapper
	{
	public:
		/** Constructor.

			When created, this will register itself with the filter for changes. It's 
			safe to assume that the filter won't be deleted before this object is.
		*/
		MainGui (MainAudioEffect* const ownerFilter);

		/** Destructor. */
		~MainGui();


		void paintOverChildren (Graphics& g); 		// EditorCompWrapper
		void handleAsyncUpdate();	// EditorCompWrapper

#ifdef JUCE_WIN32
		void mouseDown (const MouseEvent&);	// EditorCompWrapper

		void broughtToFront();	//EditorCompWrapper
#endif

		//==============================================================================
		/** Our demo filter is a ChangeBroadcaster, and will call us back when one of 
			its parameters changes.
		*/
		void changeListenerCallback (void* source);

		void sliderValueChanged (Slider*);

		//==============================================================================
		/** Standard Juce paint callback. */
		void paint (Graphics& g);

		/** Standard Juce resize callback. */
		void resized(); // also because of EditorCompWrapper (childBoundsChanged)	

		void moved(); // EditorCompWrapper (childBoundsChanged)		

		MainAudioEffect* getOwnerFilter() const throw()         { return ownerFilter; }
	    

	private:
		//==============================================================================
		Slider* gainSlider;
		MidiKeyboardComponent* midiKeyboard;
		Label* infoLabel;
		ResizableCornerComponent* resizer;
		ComponentBoundsConstrainer resizeLimits;
		TooltipWindow tooltipWindow;
		MidiKeyboardState keyboardState;


		void updateParametersFromFilter();

		// handy wrapper method to avoid having to cast the filter to a DemoJuceFilter
		// every time we need it.. Helgo: Fuck it to hell!
		MainAudioEffect* getFilter() const throw()       { return (MainAudioEffect*) getOwnerFilter(); }

		void boundsChanged ();

		MainAudioEffect* const ownerFilter;
	};
}

#ifdef _MSC_VER
  #pragma pack (pop)
#endif

#endif
